package cn.mall.common.relation;

import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.dubbo.rpc.RpcException;

public class RelationDubboFilter implements Filter {

	@Override
	public Result invoke(Invoker<?> invoker, Invocation invocation)
			throws RpcException {
		RpcContext context = RpcContext.getContext();
		if (context.isConsumerSide()) {
			RelationKit.putRelationInfo(context);
		} else if (context.isProviderSide()) {
			RelationKit.initRelationFrom(context);
		}
		return invoker.invoke(invocation);
	}

}
